package com.moyq5.permit.center.bean.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

import com.moyq5.permit.center.bean.embed.MerchAdminId;

/**
 * 商家管理员
 * @author Moyq5
 * @date 2018年4月13日
 */
@Entity
@Table(name = "uc_merch_admin")
@DynamicUpdate
public class MerchAdmin implements java.io.Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 商家管理员ID
	 */
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "merchId", column = @Column(name = "merch_id", nullable = false, precision = 15, scale = 0)),
			@AttributeOverride(name = "adminId", column = @Column(name = "admin_id", nullable = false, precision = 15, scale = 0)) })
	private MerchAdminId id;
	/**
	 * 商家
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "merch_id", nullable = false, insertable = false, updatable = false)
	private Merch merch;
	/**
	 * 管理员
	 */	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "admin_id", nullable = false, insertable = false, updatable = false)
	private SysAdmin admin;
	/**
     * 角色，多个角色id用,号隔开
     */
    @Column(name = "roles", length = 1000)
    private String roles;
	public MerchAdminId getId() {
		return id;
	}
	public void setId(MerchAdminId id) {
		this.id = id;
	}
	public Merch getMerch() {
		return merch;
	}
	public void setMerch(Merch merch) {
		this.merch = merch;
	}
	public SysAdmin getAdmin() {
		return admin;
	}
	public void setAdmin(SysAdmin admin) {
		this.admin = admin;
	}
	public String getRoles() {
		return roles;
	}
	public void setRoles(String roles) {
		this.roles = roles;
	}
	@Override
	public String toString() {
		return "MerchAdmin [id=" + id + ", merch=" + merch + ", admin=" + admin + ", roles=" + roles + "]";
	}
	
}
